package net.aiion.weave.impl.naming;

import net.aiion.weave.spi.naming.Context;
import net.aiion.weave.spi.naming.Contextual;
import net.aiion.weave.spi.naming.UserContext;
import net.aiion.weave.spi.naming.annotations.UserScoped;

public class UserContextImpl extends ContextImpl implements UserContext
{
    private static final String USER_CONTEXT_NAME = UserContext.class.getName();

    public UserContextImpl(final Context aParentContext) {
        super(UserScoped.class);
        setParentContext(aParentContext);
    }

    @Override
    protected Contextual lookupContext(final String bindingName) {
        if (USER_CONTEXT_NAME.equals(bindingName)) {
            return bind(bindingName, this);
        }

        return super.lookupContext(bindingName);
    }
}
